<template lang="html">
    <div class="diaryList">
        <myHeader>
            <div class="add-icon">
                <i class="iconfont icon-add" @click="addDiary"></i>
            </div>
        </myHeader>
        <div class="list-container">
            <group>
                <cell v-for="(item,index) in diaryList" :key="index" :title="item.time" :value="item.whether" :link="`/remember/diary?id=${item.id}`"></cell>
            </group>
        </div>
    </div>
</template>

<script>
import { Cell,Group } from 'vux'
export default {
    components: {
        Cell,
        Group
    },
    data(){
        return {
            diaryList: []
        }
    },
    methods: {
        addDiary(){
            this.$router.push({
                name: 'rememberDiary'
            })
        },
        getList(){
            this.$vux.loading.show({
                text: '加载中'
            })
            this.$api.get('/diary/list').then(res => {
                this.$vux.loading.hide()
                this.diaryList = res
            })
        }
    },
    created(){
        this.getList()
    }
}
</script>

<style lang="scss" scoped>
    .diaryList{
        .add-icon{
            font-size: .16rem;
            text-align: right;
            padding: 0 .1rem;
        }
    }
</style>
